package com.tanhua.model.vo;

import com.tanhua.model.mongo.RecommendUser;
import com.tanhua.model.domain.UserInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

/**
 * @author Xiao
 * @date 2021/10/24
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TodayBest implements Serializable {
    private static final long serialVersionUID = 1L;
    private Long id; //用户id
    private String avatar;
    private String nickname;
    private String gender; //性别 man woman
    private Integer age;
    private String[] tags;
    private Long fateValue; //缘分值

    /**
     * 在vo对象中，补充一个工具方法，封装转化过程
     */
    public static TodayBest init(UserInfo userInfo, RecommendUser recommendUser) {
        TodayBest todayBest = new TodayBest();
        BeanUtils.copyProperties(userInfo, todayBest);
        if(userInfo.getTags() != null) {
            todayBest.setTags(userInfo.getTags().split(","));
        }
        todayBest.setFateValue(recommendUser.getScore().longValue());
        return todayBest;
    }
}
